<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="change" class="change">
  <h1 text="true" style="background-color: red">Hello, World!</h1>
  <h1 text="false" style="background-color: green">Hello, World!</h1>
</div>

<script >
  let elements = document.querySelectorAll("#change>h1");
  for (let i = 0; i < elements.length; i++) {
    // console.log(elements[i]);
      let attribute = elements[i].getAttribute("text");
      console.log(attribute);
      elements[i].innerText = attribute;

      elements[i].removeAttribute("text");
  }

</script>

</body>
</html>